@include('admin._include.header')

<body>

<div class="layui-fluid">
    <div class="larry-container">
        <div class="layui-row layui-col-space15 larryms-data-top">
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md12 layui-col-lg12">
                <table lay-filter="ad_table" class="layui-table" lay-data="{height:'full-155',cellMinWidth:95,url:'{{url('store/express')}}', page:true, id:'ad_table',toolbar:'#tools',defaultToolbar:[]}">
                    <thead>
                    <tr>
                        <th lay-data="{field:'id',align:'center'}">ID</th>
                        <th lay-data="{field:'name',align:'center'}">快递名称</th>
                        <th lay-data="{toolbar:'#toolbarDemo',width:200,align:'center'}">logo</th>
                        <th lay-data="{field:'code',align:'center'}">code</th>
                        <th lay-data="{align:'center',templet:'#status'}">状态</th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="toolbarDemo" class="layer-photos-demo">
    <img src="@{{ d.logo }}" width="100px" height="50px" layer-src="@{{ d.logo }}" alt="" lay-event="show">
</script>

<script type="text/html" id="status">
    @{{# if (d.status == 1) { }}
    <input type="checkbox" checked="true" lay-filter="status" value="@{{d.id}}" lay-skin="switch" lay-text="启用|禁用">
    @{{# } else {}}
    <input type="checkbox"  value="@{{d.id}}" lay-filter="status" lay-skin="switch" lay-text="启用|禁用">
    @{{# }}}
</script>

<script>
    layui.config({
        base: "/plugin/layuiadmin/"  //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table'], function(){
        var $ = layui.$,
            form = layui.form,
            table = layui.table;

        form.on('switch(status)', function(data){
            var bool = data.elem.checked;
            var id = data.value;
            if (bool) {
                var status = 1;
            } else {
                var status = 0;
            }
            var index = layer.load(1);
            var url = "{{url('store/express-edit')}}";

            $.ajax({
                url:url,
                dateType:'json',
                data:{id:id,status:status},
                beforeSend:function() {

                },
                type:'post',
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                success:function (res) {
                    layer.close(index);
                    layer.msg("操作成功",{time:800,shade:0.3},function () {
                        table.reload('ad_table')
                    });
                }
            })
        });

    });

</script>
</body>

@include('admin._include.footer')


